package com.huawei.java.model;

import java.util.List;
import java.util.Objects;

public class ClientNode implements Comparable<ClientNode>{
    private String name;

    private int bandwidth;

    private List<SiteNode> validSiteNodes;

    public ClientNode(String name) {
        this.name = name;
    }

    public int getBandwidth() {
        return bandwidth;
    }

    public void setBandwidth(int bandwidth) {
        this.bandwidth = bandwidth;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<SiteNode> getValidSiteNodes() {
        return validSiteNodes;
    }

    public void setValidSiteNodes(List<SiteNode> validSiteNodes) {
        this.validSiteNodes = validSiteNodes;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ClientNode that = (ClientNode) o;
        return Objects.equals(name, that.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name);
    }

    @Override
    public int compareTo(ClientNode o) {
        int i = this.validSiteNodes.size() - o.validSiteNodes.size();
        return i == 0 ? 1 : i;
    }

    @Override
    public String toString() {
        return "ClientNode{" +
                "name='" + name + '\'' +
                ", bandwidth=" + bandwidth +
                ", validSiteNodes=" + validSiteNodes.size() +
                '}';
    }
}
